/**
* 模块名: 博客后台api归档
* 代码描述: 博客后台api归档
* 作者: lizibin
* 创建时间:2023/01/22 21:53:51
*/
import request from "@/utils/request"
import { AnyARecord } from "dns"
import { Res, ResData, AllArticleInfoItf, AllClassifyInfo, CommentType, ResList, UrlInfoItf,VisitInfoItf } from "./types"
// import { GetCommentByArticleIdITF } from "../foreground/types"

// 查询当前登录用户编写文章总数量
export function GetArticleCountByUserId(params: { userId: number }): Promise<Res<number>> {
    return request({
        url: '/article/showArticleCountByUserId',
        method: 'GET',
        params
    })
}


// 查询注册用户总数
export function GetUserCount(): Promise<Res<number>> {
    return request({
        url: '/user/showUserCount',
        method: 'GET',
    })
}

// 查询通过审核的文章总数量
export function GetArticleCount(): Promise<Res<number>> {
    return request({
        url: '/article/showArticleCount',
        method: 'GET',
    })
}

// 查询评论总数
export function GetCommentCount(): Promise<Res<number>> {
    return request({
        url: '/comment/count',
        method: 'GET',
    })
}

// 添加文章
export function InsertVisitInfo(data: any): Promise<Res<unknown>> {
    return request({
        url: '/article/insertArticleInfo',
        method: 'post',
        data
    })
}
// 增加分类对应的文章数量
export function UpdateArticleNumberByClassifyId(params: { classifyId: number | string }): Promise<Res<number>> {
    return request({
        url: '/comment/count',
        method: 'GET',
        params
    })
}

// 分页获取文章
export function GetArticle(params: any): Promise<ResData<AllArticleInfoItf>> {
    return request({
        url: '/article/page/byUserType',
        method: 'GET',
        params
    })
}

// 查询文章-文章名
export function SearchArticle(params: any): Promise<ResData<AllArticleInfoItf>> {
    return request({
        url: '/article/search/title',
        method: 'GET',
        params
    })
}

// 查询文章-审核状态
export function SearchArticlePass(params: any): Promise<ResData<AllArticleInfoItf>> {
    return request({
        url: '/article/search/pass',
        method: 'GET',
        params
    })
}

// 审核
export function UpdateArticlePass(params: any): Promise<Res<unknown>> {
    return request({
        url: '/article/updateArticlePass',
        method: 'GET',
        params
    })
}

// 删除文章
export function DeleteArticle(params: { articleId: number | string }): Promise<Res<unknown>> {
    return request({
        url: '/article/delete',
        method: 'DELETE',
        params
    })
}

// 删除评论
export function DeleteComment(params: { commentId: number | string }): Promise<Res<unknown>> {
    return request({
        url: '/comment/delete',
        method: 'DELETE',
        params
    })
}

export function DeleteByArticleId(params: { articleId: any }): Promise<Res<unknown>> {
    return request({
        url: '/article/delete',
        method: 'DELETE',
        params
    })
}

export function UpdateArticleNumberByClassifyId2(params: { classifyId: number | string }): Promise<Res<unknown>> {
    return request({
        url: '/article/delete',
        method: 'DELETE',
        params
    })
}

// 分类文章+1
export function ClassArticleAdd(params: any): Promise<Res<unknown>> {
    return request({
        url: '/classify/updateArticleNumberByClassifyId',
        method: 'GET',
        params
    })
}

// 分类文章-1
export function ClassArticleReduce(params: any): Promise<Res<unknown>> {
    return request({
        url: '/classify/updateArticleNumberByClassifyId2',
        method: 'GET',
        params
    })
}

// 修改文章
export function EditArtilceInfo(data: any): Promise<Res<unknown>> {
    return request({
        url: '/article/updateArticleInfo',
        method: 'POST',
        data
    })
}

// 全部分类
export function ShowAllClassifyInfo(): Promise<ResData<AllClassifyInfo>> {
    return request({
        url: '/classify/showAllClassifyInfo',
        method: 'GET',
    })
}
// 删除分类
export function DeleteClassify(params: { classifyId: number | string }): Promise<Res<unknown>> {
    return request({
        url: '/classify/delete',
        method: 'DELETE',
        params
    })
}

// 新增分类
export function InsertClassify(data: any): Promise<Res<unknown>> {
    return request({
        url: '/classify/insert',
        method: 'POST',
        data
    })
}

// 修改分类
export function UpdateClassify(data: any): Promise<Res<unknown>> {
    return request({
        url: '/classify/update',
        method: 'POST',
        data
    })
}

// 查询评论  这个返回值有点离谱，后期优化，先不做类型处理
export function GetCommentList(params: any): Promise<any> {
    return request({
        url: '/comment/page/byUserType',
        method: 'GET',
        params
    })
}

// 删除用户
export function DeleteUser(params: { userId: number | string }): Promise<Res<unknown>> {
    return request({
        url: '/user/delete',
        method: 'DELETE',
        params
    })
}

// 查询用户
export function GetUser(params: any): Promise<any> {
    return request({
        url: '/user/page/findby',
        method: 'GET',
        params
    })
}

// 验证用户名
export function CheckUserName(params: any): Promise<Res<unknown>> {
    return request({
        url: '/user/showUserName',
        method: 'GET',
        params
    })
}

// 验证邮箱
export function CheckUserEmail(params: any): Promise<Res<unknown>> {
    return request({
        url: '/email/sendEmail',
        method: 'GET',
        params
    })
}

// 修改用户 
// 这个接口忘记写了 go里面没有
export function UpdateUserInfo(data: any): Promise<Res<unknown>> {
    return request({
        url: '/user/updateUserInfo',
        method: 'POST',
        data
    })
}

// 查询全部链接
export function GetAllUrl(params: any): Promise<ResList<UrlInfoItf>> {
    return request({
        url: '/url/page/findby',
        method: 'GET',
        params
    })
}

// 审核筛选
export function GetAuditUrl(params: any): Promise<ResList<UrlInfoItf>> {
    return request({
        url: '/url/page/auditScreening',
        method: 'GET',
        params
    })
}

// 审核链接
export function UpdateUrlPass(params: any): Promise<Res<unknown>> {
    return request({
        url: '/url/updateUrlPass',
        method: 'GET',
        params
    })
}

// 删除链接
export function DeleteUrl(params: any): Promise<Res<unknown>> {
    return request({
        url: '/url/delete',
        method: 'DELETE',
        params
    })
}

// 添加链接 
export function InsertUrl(data: any): Promise<Res<unknown>> {
    return request({
        url: '/url/insert',
        method: 'POST',
        data
    })
}

// 保存设置 
export function UpdateSystemSetup(data: any): Promise<Res<unknown>> {
    return request({
        url: '/systemSetup/updateSystemSetup',
        method: 'POST',
        data
    })
}

// 查询访问信息
export function GetVisit(params: any): Promise<ResList<VisitInfoItf>> {
    return request({
        url: '/ip/getall',
        method: 'GET',
        params
    })
}

// 删除访问信息
export function DeleteVisit(params: any): Promise<Res<unknown>> {
    return request({
        url: '/ip/delete',
        method: 'DELETE',
        params
    })
}

// 删除文字
export function DeleteTest(params: any): Promise<Res<unknown>> {
    return request({
        url: '/text/delete',
        method: 'DELETE',
        params
    })
}
// 新增文字
export function AddText(data: any): Promise<Res<unknown>> {
    return request({
        url: '/text/insert',
        method: 'POST',
        data
    })
}



// 更新轮播图
export function UpdateCarouseMap(data: any): Promise<Res<unknown>> {
    return request({
        url: '/carouseMap/updateCarouseMap',
        method: 'POST',
        data
    })
}


// 修改个人信息
export function UpdateUserBasicsInfo(data: any): Promise<Res<unknown>> {
    return request({
        url: '/user/updateUserBasicsInfo',
        method: 'POST',
        data
    })
}


// 修改个人信息
export function UpdateUserPass(data: any): Promise<Res<unknown>> {
    return request({
        url: '/user/updateUserPass',
        method: 'GET',
        data
    })
}

